2012 Presidential Campaign Finance Analysis

Chisheng Li

Introduction

This project analyzes the 2012 Presidential Campaign Contributions data to compare Barack Obama's and Mitt Romney's campaign finance between March 2011 and December 2012. The dataset is obtained from the Federal Election Commission (FEC).

Dataset preparation

The dataset is downloaded and renamed to donations.txt with the following commands:

unzip P00000001-ALL.zip
mv P00000001-ALL.csv donations.txt

Exploring the data

The FEC decided that it would be cool to insert commas at the end of each line, fooling the CSV readers that there are empty fields at the end of every line. For example, the first row of the dataset is as followed:

C00410118,"P20002978","Bachmann, Michele","HARVEY, WILLIAM","MOBILE","AL","366010290","RETIRED","RETIRED",250,20-JUN-11,"","","","SA17A","736166","A1FDABC23D2D545A1B83","P2012",

pandas's file parsers treat the first column as the data frame's row name by default if the data set has 1 too many columns, hence insert index_col=False to drop the last column to display the data frame properly. The dataset has 18 columns and 6,036,458 rows.


In [17]:
import pandas as pd
import numpy as np
donations = pd.read_csv('donations.txt', dtype={'contbr_zip': 'str', 'file_num': 'str'}, index_col=False)
# How many rows and columns does the dataframe have?
donations.shape


Out[17]:
(6036458, 18)

In [2]:
# The first 5 lines of the dataset
donations.head()


Out[2]:
cmte_id cand_id cand_nm contbr_nm contbr_city contbr_st contbr_zip contbr_employer contbr_occupation contb_receipt_amt contb_receipt_dt receipt_desc memo_cd memo_text form_tp file_num tran_id election_tp
0 C00410118 P20002978 Bachmann, Michele HARVEY, WILLIAM MOBILE AL 366010290 RETIRED RETIRED 250 20-JUN-11 NaN NaN NaN SA17A 736166 A1FDABC23D2D545A1B83 P2012
1 C00410118 P20002978 Bachmann, Michele HARVEY, WILLIAM MOBILE AL 366010290 RETIRED RETIRED 50 23-JUN-11 NaN NaN NaN SA17A 736166 A899B9B0E223743EFA63 P2012
2 C00410118 P20002978 Bachmann, Michele SMITH, LANIER LANETT AL 368633403 INFORMATION REQUESTED INFORMATION REQUESTED 250 05-JUL-11 NaN NaN NaN SA17A 749073 A4B144E3CB3294ABC9D6 P2012
3 C00410118 P20002978 Bachmann, Michele BLEVINS, DARONDA PIGGOTT AR 724548253 NONE RETIRED 250 01-AUG-11 NaN NaN NaN SA17A 749073 A8C7C6F55B0914C5A880 P2012
4 C00410118 P20002978 Bachmann, Michele WARDENBURG, HAROLD HOT SPRINGS NATION AR 719016467 NONE RETIRED 300 20-JUN-11 NaN NaN NaN SA17A 736166 A070D6D560BD84AA98AC P2012

In [3]:
# Now, look at the last 5 lines
donations.tail()


Out[3]:
cmte_id cand_id cand_nm contbr_nm contbr_city contbr_st contbr_zip contbr_employer contbr_occupation contb_receipt_amt contb_receipt_dt receipt_desc memo_cd memo_text form_tp file_num tran_id election_tp
6036453 C00505800 P20003984 Stein, Jill KATAHIRA, DEAN RIPON WI 54971 RIPON COLLEGE TEACHER 100 06-SEP-12 NaN NaN NaN SA17A 823142 SA17A.16242 G2012
6036454 C00505800 P20003984 Stein, Jill YOUNG, FRANK RIPLEY WV 25271 JACKSON COUNTY RECYCLING CENTER RECYCLING PROGRAM MANAGER 250 06-SEP-12 NaN NaN NaN SA17A 823142 SA17A.16299 G2012
6036455 C00505800 P20003984 Stein, Jill RHODES, JC CODY WY 82414 RETIRED PEACE OFFICER 250 14-SEP-12 NaN NaN NaN SA17A 823142 SA17A.16868 G2012
6036456 C00505800 P20003984 Stein, Jill RHODES, JC CODY WY 82414 RETIRED PEACE OFFICER 250 09-OCT-12 NaN NaN NaN SA17A 825219 SA17A.19233 G2012
6036457 C00505800 P20003984 Stein, Jill BRAULT, CLARE MONTREAL ZZ NaN RETIRED NaN 250 03-AUG-12 NaN NaN NaN SA17A 811430 SA17A.12252 P2012

Pandas's .describe() function generates summary statistics of the entire dataset. There are 6,036,458 observations in the campaign contributions data. Although there are extreme outliers in this dataset, with the highest donation amount at \$16,387,179.20 and the lowest donation amount at -\$60,800.00, the interquartile range is moderate. The 25th percentile donation amount is \$25.00, the 75th percentile donation amount is \$150.00, and the median donation amount is \$50.00. The average donation to all presidential candidates is \$212.99, suggesting a right skewed distribution.


In [4]:
donations.describe()


Out[4]:
contb_receipt_amt
count 6036458.000000
mean 212.997098
std 8957.272203
min -60800.000000
25% 25.000000
50% 50.000000
75% 150.000000
max 16387179.200000

Sorting the campaign contributions by decreasing amount indicates that the Obama Victory Fund contributed the highest donations to Barack Obama during the 2012 president election cycle.


In [5]:
donations.sort('contb_receipt_amt', ascending=False)


Out[5]:
cmte_id cand_id cand_nm contbr_nm contbr_city contbr_st contbr_zip contbr_employer contbr_occupation contb_receipt_amt contb_receipt_dt receipt_desc memo_cd memo_text form_tp file_num tran_id election_tp
3280428 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 16387179.20 28-SEP-12 NaN X * SA18 821325 CZ22557505 G2012
3243511 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 8701608.42 31-AUG-12 NaN X * SA18 811365 CZ19625190 P2012
3142436 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 4743767.11 05-OCT-12 NaN X * SA18 846396 CZ24626997 G2012
3108174 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 4260530.67 24-OCT-12 NaN X * OBAMA VICTORY FUND 2012 SA18 840327 CZ27865768 G2012
3143563 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 4031228.17 17-OCT-12 NaN X * SA18 846396 CZ26406950 G2012
3119225 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 3761760.87 12-OCT-12 NaN X * SA18 846396 CZ25897187 G2012
3121739 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 3444452.42 31-OCT-12 NaN X * OBAMA VICTORY FUND 2012 SA18 840327 CZ28604151 G2012
3202725 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 3387248.02 30-JUN-12 NaN X * SA18 810684 CZ16639625 P2012
3220245 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 3187630.19 31-JUL-12 NaN X * SA18 806136 CZ18143031 P2012
3119743 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 2965818.76 06-NOV-12 NaN X * OBAMA VICTORY FUND 2012 SA18 840327 CZ29815072 G2012
3173321 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 2014490.51 29-FEB-12 NaN X * SA18 787803 CZ13924743 P2012
3170109 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 1944042.43 31-DEC-11 NaN X * SA18 772372 CZ12707473 P2012
3141132 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 1899641.12 13-DEC-12 NaN X * SA18 853328 CZ30123254 G2012
3220992 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 1726201.95 25-JUN-12 NaN X * SA18 810684 CZ16942888 P2012
3184571 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 1679114.65 31-MAR-12 NaN X * SA18 795675 CZ14468589 P2012
3194418 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 1617553.31 31-MAY-12 NaN X * SA18 791603 CZ15848778 P2012
3208927 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 1516412.23 21-JUN-12 NaN X * SA18 810684 CZ16696966 P2012
3153828 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 1511192.17 30-SEP-11 NaN X * SA18 756218 CZ12479139 P2012
3186265 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 526246.17 30-APR-12 NaN X * SA18 795683 CZ15207150 P2012
3172798 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 512710.91 31-JAN-12 NaN X * SA18 775668 CZ13720918 P2012
2631114 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED WASHINGTON DC 20003 NaN NaN 451726.00 30-JUN-11 NaN X * SA18 756214 CZ11677198 P2012
3140850 C00431445 P80003338 Obama, Barack OBAMA VICTORY FUND 2012 - UNITEMIZED CHICAGO IL 60680 NaN NaN 167649.97 19-DEC-12 NaN X * SA18 853328 CZ30160311 G2012
4487053 C00431445 P80003338 Obama, Barack ELMALEH, VICTOR NEW YORK NY 10017 RETIRED RETIRED 60800.00 19-JUL-12 NaN NaN NaN SA17A 806136 C18100331 P2012
4515521 C00431445 P80003338 Obama, Barack OSATO, SONO BROOKLYN NY 11211 SELF-EMPLOYED ARTIST/ PERSONAL ORGANIZER 39200.00 19-JUL-12 NaN NaN NaN SA17A 806136 C18100793 P2012
1645595 C00431445 P80003338 Obama, Barack MURPHY, CYNTHIA C. LITTLE ROCK AR 722075462 MURPHY GROUP PUBLIC RELATIONS 33300.00 25-MAY-11 NaN NaN NaN SA17A 756214 C11732268 G2012
1590975 C00431171 P80003353 Romney, Mitt MCQUILLAN, JOHN MR. JACKSON WY 830019261 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 30000.00 18-JUN-12 NaN NaN CHARGED BACK $30000.00 ON 06/21/2012 SA17A 809159 SA17.1186383A P2012
105918 C00431171 P80003353 Romney, Mitt DAVIDSON, KENNETH LOS ANGELES CA 900090125 DSD HOLDINGS LLC PARTNER 30000.00 01-JUN-12 NaN NaN CHARGED BACK $30000.00 ON 06/06/2012 SA17A 809159 SA17.1059153A P2012
492314 C00431171 P80003353 Romney, Mitt TRANKINA, TIMOTHY MR. ALPHARETTA GA 300221022 TITLEMASTER OF GA L.L.C. MANAGER 28600.00 04-JUN-12 NaN NaN CHARGED BACK $28600.00 ON 06/06/2012 SA17A 809159 SA17.1059160A P2012
2227897 C00431445 P80003338 Obama, Barack DAVIS, STEPHEN JAMES SAN FRANCISCO CA 941151123 BANNEKER PARTNERS ATTORNEY 25800.00 10-MAY-11 NaN NaN CONTRIBUTION REFUNDED ON 7/8/11 SA17A 756214 C11675250 P2012
5857070 C00495820 P80000748 Paul, Ron LIBERTY PAC LAKE JACKSON TX 77566 NaN NaN 25000.00 02-MAY-11 NaN NaN ITEMIZATION BELOW SA17A 779223 0337994 P2012
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
976175 C00431171 P80003353 Romney, Mitt BABBITT, ALBERT LAS VEGAS NV 89113 NaN NaN -10000.00 27-OCT-12 Refund NaN NaN SB28A 933479 SB28.M11.1434 G2012
1749895 C00431445 P80003338 Obama, Barack SCHULZE, MAUDE MS. REDWOOD CITY CA 940621626 NaN NaN -11700.00 25-SEP-12 Refund NaN NaN SB28A 821325 D63703 P2012
1749283 C00431445 P80003338 Obama, Barack SCHULZE, MAUDE MS. REDWOOD CITY CA 940621626 NaN NaN -11700.00 25-SEP-12 Refund NaN NaN SB28A 821325 D63702 P2012
1804895 C00431445 P80003338 Obama, Barack SCHULZE, MAUDE MS. REDWOOD CITY CA 940621626 NaN NaN -11700.00 15-AUG-12 Refund NaN NaN SB28A 811365 D53420 P2012
1355638 C00431171 P80003353 Romney, Mitt KIRK, DAVID MIDLAND TX 79705 NaN NaN -12500.00 27-OCT-12 Refund NaN NaN SB28A 933479 SB28.M11.1428 G2012
1276800 C00431171 P80003353 Romney, Mitt KIRK, DAVID MIDLAND TX 79705 NaN NaN -12500.00 27-OCT-12 Refund NaN NaN SB28A 842943 SB28.M11.1428 G2012
309020 C00431171 P80003353 Romney, Mitt ARMSTRONG, ELISABETH CHERRY HILLS VILLAGE CO 80113 NaN NaN -12500.00 27-OCT-12 Refund NaN NaN SB28A 842943 SB28.M11.1424 G2012
288125 C00431171 P80003353 Romney, Mitt ARMSTRONG, ELISABETH CHERRY HILLS VILLAGE CO 80113 NaN NaN -12500.00 27-OCT-12 Refund NaN NaN SB28A 933479 SB28.M11.1424 G2012
175224 C00431171 P80003353 Romney, Mitt MCGUIRE, DON PEBBLE BEACH CA 93953 NaN NaN -15000.00 24-SEP-12 Refund NaN NaN SB28A 822044 SB28.M91170 G2012
362049 C00431171 P80003353 Romney, Mitt MOSLING, STEPHEN NAPLES FL 34108 NaN NaN -15000.00 30-OCT-12 Refund NaN NaN SB28A 933479 SB28.M11.1480 G2012
1099189 C00431171 P80003353 Romney, Mitt ROJ, WILLIAM H. SHAKER HEIGHTS OH 44122 NaN NaN -15000.00 27-OCT-12 Refund NaN NaN SB28A 842943 SB28.M11.1427 G2012
202886 C00431171 P80003353 Romney, Mitt MCGUIRE, DON PEBBLE BEACH CA 93953 NaN NaN -15000.00 24-SEP-12 Refund NaN NaN SB28A 944828 SB28.M91170 G2012
445897 C00431171 P80003353 Romney, Mitt MOSLING, STEPHEN NAPLES FL 34108 NaN NaN -15000.00 30-OCT-12 Refund NaN NaN SB28A 842943 SB28.M11.1480 G2012
1064450 C00431171 P80003353 Romney, Mitt ROJ, WILLIAM H. SHAKER HEIGHTS OH 44122 NaN NaN -15000.00 27-OCT-12 Refund NaN NaN SB28A 933479 SB28.M11.1427 G2012
635797 C00431171 P80003353 Romney, Mitt CRAWFORD, JOHN FORT WAYNE IN 46815 NaN NaN -20000.00 03-NOV-12 Refund NaN NaN SB28A 842943 SB28.M11.1621 G2012
626592 C00431171 P80003353 Romney, Mitt CRAWFORD, JOHN FORT WAYNE IN 46815 NaN NaN -20000.00 03-NOV-12 Refund NaN NaN SB28A 933479 SB28.M11.1621 G2012
3660739 C00431445 P80003338 Obama, Barack LEE, EUGENE C. CAPT RET. HYATTSVILLE MD 207841451 NaN NaN -22500.00 02-OCT-12 Refund NaN NaN SB28A 846396 D66317 G2012
372230 C00431171 P80003353 Romney, Mitt TERLIZZI, JAMES D. MR. GULF STREAM FL 334837222 P.G.H.I. INC. BUSINESS -25000.00 18-JUL-12 NaN NaN CHARGED BACK SA17A 944286 SA17.1575666 P2012
575671 C00431171 P80003353 Romney, Mitt FREIDHEIM, CYRUS CHICAGO IL 60610 NaN NaN -25000.00 03-NOV-12 Refund NaN NaN SB28A 842943 SB28.M11.1619 G2012
599926 C00431171 P80003353 Romney, Mitt FREIDHEIM, CYRUS CHICAGO IL 60610 NaN NaN -25000.00 03-NOV-12 Refund NaN NaN SB28A 933479 SB28.M11.1619 G2012
468351 C00431171 P80003353 Romney, Mitt TERLIZZI, JAMES D. MR. GULF STREAM FL 334837222 P.G.H.I. INC. BUSINESS -25000.00 18-JUL-12 NaN NaN CHARGED BACK SA17A 821472 SA17.1575666 P2012
2218929 C00431445 P80003338 Obama, Barack DAVIS, STEPHEN JAMES SAN FRANCISCO CA 941151123 NaN NaN -25800.00 08-JUL-11 Refund NaN NaN SB28A 756218 D25224 P2012
492315 C00431171 P80003353 Romney, Mitt TRANKINA, TIMOTHY MR. ALPHARETTA GA 300221022 TITLEMASTER OF GA L.L.C. MANAGER -28600.00 06-JUN-12 NaN NaN CHARGED BACK SA17A 809159 SA17.1059160B P2012
1590976 C00431171 P80003353 Romney, Mitt MCQUILLAN, JOHN MR. JACKSON WY 830019261 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS -30000.00 21-JUN-12 NaN NaN CHARGED BACK SA17A 809159 SA17.1186383B P2012
105919 C00431171 P80003353 Romney, Mitt DAVIDSON, KENNETH LOS ANGELES CA 900090125 DSD HOLDINGS LLC PARTNER -30000.00 06-JUN-12 NaN NaN CHARGED BACK SA17A 809159 SA17.1059153B P2012
1645426 C00431445 P80003338 Obama, Barack MURPHY, CYNTHIA C. LITTLE ROCK AR 722075462 NaN NaN -30800.00 15-JUN-11 Refund NaN NaN SB28A 756214 D24799 G2012
4527742 C00431445 P80003338 Obama, Barack OSATO, SONO BROOKLYN NY 11211 NaN NaN -34225.00 20-JUL-12 Refund NaN NaN SB28A 806136 D47207 P2012
4527738 C00431445 P80003338 Obama, Barack OSATO, SONO BROOKLYN NY 11211 NaN NaN -34225.00 20-JUL-12 Refund NaN NaN SB28A 806136 D47206 P2012
4527758 C00431445 P80003338 Obama, Barack OSATO, SONO BROOKLYN NY 11211 NaN NaN -39200.00 24-JUL-12 Refund NaN NaN SB28A 806136 D47218 P2012
4527711 C00431445 P80003338 Obama, Barack ELMALEH, VICTOR NEW YORK NY 10017 NaN NaN -60800.00 20-JUL-12 Refund NaN NaN SB28A 806136 D47223 P2012

6036458 rows × 18 columns

Basic campaign finance statistics

Subset the positive campaign donations to President Barack Obama:


In [6]:
obama = donations[(donations['cand_nm'] == 'Obama, Barack') & 
                  (donations['contb_receipt_amt'] > 0)]
obama


Out[6]:
cmte_id cand_id cand_nm contbr_nm contbr_city contbr_st contbr_zip contbr_employer contbr_occupation contb_receipt_amt contb_receipt_dt receipt_desc memo_cd memo_text form_tp file_num tran_id election_tp
1594097 C00431445 P80003338 Obama, Barack SMITH, MAUREEN P. UNITED KINGDOM AA NaN HOMEMAKER HOMEMAKER 1000 28-OCT-12 NaN NaN NaN SA17A 840327 C28501220 G2012
1594098 C00431445 P80003338 Obama, Barack HAWLEY, JULIA DPO AA 340310243 USG FED AGENT 40 31-OCT-12 NaN X * OBAMA VICTORY FUND 2012 SA18 840327 C30086573 G2012
1594099 C00431445 P80003338 Obama, Barack HAWLEY, JULIA DPO AA 340310243 USG FED AGENT 40 30-OCT-12 NaN X * OBAMA VICTORY FUND 2012 SA18 840327 C29942338 G2012
1594100 C00431445 P80003338 Obama, Barack MOASE, BENNETT TORONTO AA 33884 DISABLED DISABLED 8 05-NOV-12 NaN X * OBAMA VICTORY FUND 2012 SA18 840327 C30067205 G2012
1594101 C00431445 P80003338 Obama, Barack MOASE, BENNETT TORONTO AA 33884 DISABLED DISABLED 8 05-NOV-12 NaN X * OBAMA VICTORY FUND 2012 SA18 840327 C30071746 G2012
1594102 C00431445 P80003338 Obama, Barack PETTY, ROBERT HONG KONG AA 06524 CLEARWATER CAPITAL PARTNERS INVESTOR 1000 29-OCT-12 NaN X * OBAMA VICTORY FUND 2012 SA18 840327 C29941789 G2012
1594107 C00431445 P80003338 Obama, Barack GREICIUS, LUKE DPO AA 34030 US DEPT OF STATE DIPLOMAT 250 22-OCT-12 NaN NaN NaN SA17A 840327 C27522149 G2012
1594108 C00431445 P80003338 Obama, Barack GASSAM, GERALDINE DPO AA 340230111 U.S. DEPARTMENT OF STATE FOREIGN SERVICE OFFICER 17 22-OCT-12 NaN NaN NaN SA17A 840327 C27557910 G2012
1594109 C00431445 P80003338 Obama, Barack GILL, BATES MAERSTA AA 19592 SIPRI DIRECTOR 281 21-OCT-12 NaN NaN NaN SA17A 840327 C26867814 G2012
1594110 C00431445 P80003338 Obama, Barack GOLEC KENIGER, SHARON PARIS AA 75014 LEGALTEAM SOLUTIONS CONSULTANT 100 28-OCT-12 NaN NaN NaN SA17A 840327 C28502641 G2012
1594111 C00431445 P80003338 Obama, Barack GOLEC KENIGER, SHARON PARIS AA 75014 LEGALTEAM SOLUTIONS CONSULTANT 95 06-NOV-12 NaN NaN NaN SA17A 840327 C29786059 G2012
1594112 C00431445 P80003338 Obama, Barack FUND, HARRY CARLSBAD AA 92009 RETIRED RETIRED 50 19-OCT-12 NaN NaN NaN SA17A 840327 C26772467 G2012
1594113 C00431445 P80003338 Obama, Barack FUND, HARRY CARLSBAD AA 92009 RETIRED RETIRED 50 26-OCT-12 NaN NaN NaN SA17A 840327 C28333861 G2012
1594114 C00431445 P80003338 Obama, Barack FUND, HARRY CARLSBAD AA 92009 RETIRED RETIRED 50 31-OCT-12 NaN NaN NaN SA17A 840327 C28750360 G2012
1594115 C00431445 P80003338 Obama, Barack FUND, HARRY CARLSBAD AA 92009 RETIRED RETIRED 50 01-NOV-12 NaN NaN NaN SA17A 840327 C28950021 G2012
1594116 C00431445 P80003338 Obama, Barack HERNANDEZ, NINA DENISE DPO AA 34025 PEACE CORPS COUNTRY DIRECTOR 19 22-OCT-12 NaN NaN NaN SA17A 840327 C27572077 G2012
1594117 C00431445 P80003338 Obama, Barack HERNANDEZ, NINA DENISE DPO AA 34025 PEACE CORPS COUNTRY DIRECTOR 35 22-OCT-12 NaN NaN NaN SA17A 840327 C27572076 G2012
1594118 C00431445 P80003338 Obama, Barack HERNANDEZ, NINA DENISE DPO AA 34025 PEACE CORPS COUNTRY DIRECTOR 100 30-OCT-12 NaN NaN NaN SA17A 840327 C28691368 G2012
1594119 C00431445 P80003338 Obama, Barack HARRIS, PAMELA APO AA 340385127 CCE RETIRED 100 01-NOV-12 NaN NaN NaN SA17A 840327 C28973652 G2012
1594120 C00431445 P80003338 Obama, Barack MOASE, BENNETT TORONTO AA 33884 DISABLED DISABLED 8 02-NOV-12 NaN NaN NaN SA17A 840327 C29359494 G2012
1594121 C00431445 P80003338 Obama, Barack MOASE, BENNETT TORONTO AA 33884 DISABLED DISABLED 8 02-NOV-12 NaN NaN NaN SA17A 840327 C29233638 G2012
1594122 C00431445 P80003338 Obama, Barack MOASE, BENNETT TORONTO AA 33884 DISABLED DISABLED 8 02-NOV-12 NaN NaN NaN SA17A 840327 C29431602 G2012
1594123 C00431445 P80003338 Obama, Barack MOASE, BENNETT TORONTO AA 33884 DISABLED DISABLED 8 03-NOV-12 NaN NaN NaN SA17A 840327 C29608731 G2012
1594124 C00431445 P80003338 Obama, Barack BRIDGEWATER, PAMELA DPO AA 340080001 DEPT. OF STATE DIPLOMAT 281 04-NOV-12 NaN NaN NaN SA17A 840327 C29718224 G2012
1594125 C00431445 P80003338 Obama, Barack BORKOWICZ, BRANDON DPO AA 340049997 U.S. DEPARTMENT OF STATE FOREIGN SERVICE OFFICER 19 27-OCT-12 NaN NaN NaN SA17A 840327 C28346449 G2012
1594126 C00431445 P80003338 Obama, Barack BORKOWICZ, BRANDON DPO AA 340049997 U.S. DEPARTMENT OF STATE FOREIGN SERVICE OFFICER 50 02-NOV-12 NaN NaN NaN SA17A 840327 C29502329 G2012
1594127 C00431445 P80003338 Obama, Barack MENCER, KRISTIN DPO AA 340550118 STATE DEPARTMENT FOREIGN SERVICE OFFICER 41 02-NOV-12 NaN NaN NaN SA17A 840327 C29488256 G2012
1594128 C00431445 P80003338 Obama, Barack MOASE, BENNETT TORONTO AA 33884 DISABLED DISABLED 8 18-OCT-12 NaN NaN NaN SA17A 840327 C26521175 G2012
1594129 C00431445 P80003338 Obama, Barack MOASE, BENNETT TORONTO AA 33884 DISABLED DISABLED 3 27-OCT-12 NaN NaN NaN SA17A 840327 C28356165 G2012
1594130 C00431445 P80003338 Obama, Barack MOASE, BENNETT TORONTO AA 33884 DISABLED DISABLED 3 27-OCT-12 NaN NaN NaN SA17A 840327 C28387771 G2012
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
5711469 C00431445 P80003338 Obama, Barack TUCKER, PAMELA APO ZZ 963190030 DEPT OF DEFENSE SCHOOLS EDUCATOR 50 28-SEP-12 NaN NaN NaN SA17A 821325 C23280599 G2012
5711470 C00431445 P80003338 Obama, Barack RHODES, MATTHEW APO ZZ 09053 GEORGE MARSHALL CENTER PROFESSOR 500 20-SEP-12 NaN NaN NaN SA17A 821325 C22536387 G2012
5711471 C00431445 P80003338 Obama, Barack GUIFFRE, PETER DAVID FPO ZZ 963791700 DODDS SCHOOL PSYCHOLOGIST 250 01-SEP-12 NaN NaN NaN SA17A 821325 C20538897 P2012
5711472 C00431445 P80003338 Obama, Barack HARRIS, STEPHEN APO ZZ 340385127 CCE DIRECTOR 100 30-SEP-12 NaN NaN NaN SA17A 821325 C23586617 G2012
5711473 C00431445 P80003338 Obama, Barack VAN NIMMEN, JANE VIENNA ZZ 01080 RETIRED RETIRED 1000 05-SEP-12 NaN NaN NaN SA17A 821325 C20797106 P2012
5711474 C00431445 P80003338 Obama, Barack TIMONIER, NICOLE CHENE-BOUGERIES ZZ 01224 EVERGREENE ART GALLERY 500 26-SEP-12 NaN NaN NaN SA17A 821325 C23087415 G2012
5711475 C00431445 P80003338 Obama, Barack ARMSTRONG WATTERS, RICHARD SYDNEY ZZ 02074 HEREWARD PTY LTD ACCOUNTANT 1000 05-SEP-12 NaN NaN NaN SA17A 821325 C20738922 P2012
5711476 C00431445 P80003338 Obama, Barack STCHERBATCHEFF, BARBARA LONDON ZZ W1G 8 JC RATHBONE FINANCE 250 15-AUG-12 NaN X * OBAMA VICTORY FUND 2012 SA18 811365 C21561497 P2012
5711477 C00431445 P80003338 Obama, Barack DICKINSON, WARREN WELLINGTON ZZ 06012 VICTORIA UNIVERSITY GEOLOGIST 250 29-AUG-12 NaN X * OBAMA VICTORY FUND 2012 SA18 811365 C21712395 P2012
5711478 C00431445 P80003338 Obama, Barack PRELEC, MARKO THE HAGUE ZZ 2518 INTERNATIONAL CRISIS GROUP SENIOR ANALYST 1000 31-AUG-12 NaN NaN NaN SA17A 811365 C20403587 P2012
5711479 C00431445 P80003338 Obama, Barack SELLECK, LAURA TORONTO ZZ M4G1A RYERSON UNIVERSITY RETIRED 500 29-AUG-12 NaN NaN NaN SA17A 811365 C20053356 P2012
5711480 C00431445 P80003338 Obama, Barack TUCKER, PAMELA APO ZZ 963190030 DEPT OF DEFENSE SCHOOLS EDUCATOR 50 30-AUG-12 NaN NaN NaN SA17A 811365 C20171545 P2012
5711481 C00431445 P80003338 Obama, Barack HARRIS, STEPHEN APO ZZ 340385127 CCE DIRECTOR 100 31-AUG-12 NaN NaN NaN SA17A 811365 C20317145 P2012
5711482 C00431445 P80003338 Obama, Barack DEVAUX, PETER QUALICUM BEACH ZZ V9K2L NOT EMPLOYED RETIRED 500 12-AUG-12 NaN NaN NaN SA17A 811365 C19176483 P2012
5711483 C00431445 P80003338 Obama, Barack HENRY, WANDA M. APO ZZ 34023 USAID CONTRACTING OFFICER 150 11-AUG-12 NaN NaN NaN SA17A 811365 C19127294 P2012
5711484 C00431445 P80003338 Obama, Barack GOLDSTINE, RAYMOND APO ZZ 09831 CDC PUBLIC HEALTH ADVISOR 250 12-AUG-12 NaN NaN NaN SA17A 811365 C19165403 P2012
5711485 C00431445 P80003338 Obama, Barack BEERY, JAMES LONDON ZZ W8 5H COVINGTON & BURLING LAWYER 500 30-AUG-12 NaN NaN NaN SA17A 811365 C20085303 P2012
5711486 C00431445 P80003338 Obama, Barack DEVAUX, PETER QUALICUM BEACH ZZ V9K2L NOT EMPLOYED RETIRED 1500 26-AUG-12 NaN NaN NaN SA17A 811365 C19885872 G2012
5711487 C00431445 P80003338 Obama, Barack DEVAUX, PETER QUALICUM BEACH ZZ V9K2L NOT EMPLOYED RETIRED 500 12-AUG-12 NaN NaN NaN SA17A 811365 C19176482 P2012
5711488 C00431445 P80003338 Obama, Barack DEVAUX, PETER QUALICUM BEACH ZZ V9K2L NOT EMPLOYED RETIRED 1500 26-AUG-12 NaN NaN NaN SA17A 811365 C19885462 P2012
5711491 C00431445 P80003338 Obama, Barack GOLDSTINE, RAYMOND APO ZZ 09831 CDC PHARMACIST 400 21-JUL-12 NaN X * OBAMA VICTORY FUND 2012 SA18 806136 C18981586 P2012
5711492 C00431445 P80003338 Obama, Barack BAYER, JOANNE PURKERSDORF ZZ 03002 IIASA ECONOMIST 250 30-JUL-12 NaN NaN NaN SA17A 806136 C18471726 P2012
5711493 C00431445 P80003338 Obama, Barack MOUNTS, ROBERT APO ZZ 962043077 HQ USFK (FKDC-SA) GS-15 INTERNATIONAL RELATIONS OFFICER 25 28-JUL-12 NaN NaN NaN SA17A 806136 C18390547 P2012
5711494 C00431445 P80003338 Obama, Barack STCHERBATCHEFF, BARBARA LONDON ZZ W1G 8 JC RATHBONE FINANCE 450 01-JUN-12 NaN X * OBAMA VICTORY FUND 2012 SA18 810684 C17544728 P2012
5711495 C00431445 P80003338 Obama, Barack VEDAM, SARASWATHI VANCOUVER ZZ V6K1N UNIVERSITY OF BRITISH COLUMBIA PROFESSOR AND MIDWIFE 250 03-JUN-12 NaN NaN NaN SA17A 810684 C16277244 P2012
5711496 C00431445 P80003338 Obama, Barack GOLDSTINE, RAYMOND APO ZZ 09831 CDC PUBLIC HEALTH ADVISOR 250 18-JUN-12 NaN NaN NaN SA17A 810684 C16634478 P2012
5711497 C00431445 P80003338 Obama, Barack MORGAN, HURMAYONNE APO ZZ 097029995 GOVERNMENT MILITARY 250 26-JUN-12 NaN X * OBAMA VICTORY FUND 2012 SA18 810684 C17740146 P2012
5711498 C00431445 P80003338 Obama, Barack HENRY, WANDA M APO ZZ 34023 USAID CONTRACTING OFFICER 150 28-JUN-12 NaN NaN NaN SA17A 810684 C16988280 P2012
5711499 C00431445 P80003338 Obama, Barack SIENA, JOHN LONDON ZZ SW19 BROWN BROTHERS HARRIMAN ATTORNEY 400 12-MAY-12 NaN X * OBAMA VICTORY FUND 2012 SA18 791603 C16455221 P2012
5711500 C00431445 P80003338 Obama, Barack MOUNTS, ROBERT APO ZZ 962043077 HQ USFK (FKDC-SA) GS-15 INTERNATIONAL RELATIONS OFFICER 25 26-MAY-12 NaN NaN NaN SA17A 791603 C16008108 P2012

4078945 rows × 18 columns

Subset the positive campaign donations to Mitt Romney:


In [7]:
romney = donations[(donations['cand_nm'] == 'Romney, Mitt') & 
                  (donations['contb_receipt_amt'] > 0)]
romney


Out[7]:
cmte_id cand_id cand_nm contbr_nm contbr_city contbr_st contbr_zip contbr_employer contbr_occupation contb_receipt_amt contb_receipt_dt receipt_desc memo_cd memo_text form_tp file_num tran_id election_tp
411 C00431171 P80003353 Romney, Mitt CLARK, MICHAEL FORT MEYERS 33 33908 RETIRED NONE 200 21-SEP-12 NaN NaN NaN SA17A 822044 SA17.2726391 G2012
412 C00431171 P80003353 Romney, Mitt CALIENES, GLADYS MS. GABLES 33 33146 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 100 12-SEP-12 NaN NaN NaN SA17A 822044 SA17.2588087 G2012
413 C00431171 P80003353 Romney, Mitt HOUSMAN, STEVEN WESTON 33 33327 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 225 06-SEP-12 NaN NaN NaN SA17A 822044 SA17.2391328 G2012
414 C00431171 P80003353 Romney, Mitt CLARK, MICHAEL FORT MEYERS 33 33908 RETIRED RETIRED 126 13-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2547714.26.V008 G2012
415 C00431171 P80003353 Romney, Mitt HOUSMAN, STEVEN WESTON 33 33327 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 225 06-SEP-12 NaN NaN NaN SA17A 944828 SA17.2391328 G2012
416 C00431171 P80003353 Romney, Mitt CLARK, MICHAEL FORT MEYERS 33 33908 RETIRED NONE 200 21-SEP-12 NaN NaN NaN SA17A 944828 SA17.2726391 G2012
417 C00431171 P80003353 Romney, Mitt CALIENES, GLADYS MS. GABLES 33 33146 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 100 12-SEP-12 NaN NaN NaN SA17A 944828 SA17.2588087 G2012
418 C00431171 P80003353 Romney, Mitt CLARK, MICHAEL FORT MEYERS 33 33908 RETIRED RETIRED 126 13-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 822044 SA18.2547714.26.V008 G2012
419 C00431171 P80003353 Romney, Mitt KARPINSKI, MARILYN BIG OTTER LAKES 46 46737 N/Z RETIRED 110 13-SEP-12 NaN NaN NaN SA17A 822044 SA17.2532613 G2012
420 C00431171 P80003353 Romney, Mitt KARPINSKI, MARILYN BIG OTTER LAKES 46 46737 RETIRED RETIRED 41 03-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 822044 SA18.2349192.26.V006 G2012
421 C00431171 P80003353 Romney, Mitt KARPINSKI, MARILYN BIG OTTER LAKES 46 46737 RETIRED RETIRED 50 13-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 822044 SA18.2544215.26.V008 G2012
422 C00431171 P80003353 Romney, Mitt KARPINSKI, MARILYN BIG OTTER LAKES 46 46737 RETIRED RETIRED 50 13-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2544215.26.V008 G2012
423 C00431171 P80003353 Romney, Mitt KARPINSKI, MARILYN BIG OTTER LAKES 46 46737 N/Z RETIRED 110 13-SEP-12 NaN NaN NaN SA17A 944828 SA17.2532613 G2012
424 C00431171 P80003353 Romney, Mitt KARPINSKI, MARILYN BIG OTTER LAKES 46 46737 RETIRED RETIRED 41 03-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2349192.26.V006 G2012
425 C00431171 P80003353 Romney, Mitt UMANA, JUANITA MS. ANN ARBOR 48 48198 HOMEMAKER HOMEMAKER 200 19-SEP-12 NaN NaN NaN SA17A 822044 SA17.2676701 G2012
426 C00431171 P80003353 Romney, Mitt UMANA, JUANITA MS. ANN ARBOR 48 48198 HOMEMAKER HOMEMAKER 200 19-SEP-12 NaN NaN NaN SA17A 944828 SA17.2676701 G2012
427 C00431171 P80003353 Romney, Mitt JOHNSON, LYNN MR. BATTLECREEK 49 49015 RETIRED RETIRED 100 09-OCT-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 842943 SA18.3352432.26.V012 G2012
428 C00431171 P80003353 Romney, Mitt OLSEN, JUDITH RAMSEY 7 07446 SELF HOMEMAKER 55 07-SEP-12 NaN NaN NaN SA17A 822044 SA17.2412909 G2012
429 C00431171 P80003353 Romney, Mitt OLSEN, JUDITH RAMSEY 7 07446 HOMEMAKER HOMEMAKER 74 10-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 822044 SA18.2466154.26.V007 G2012
430 C00431171 P80003353 Romney, Mitt OLSEN, JUDITH RAMSEY 7 07446 HOMEMAKER HOMEMAKER 500 08-OCT-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 827761 SA18.3252287.26.V011 G2012
431 C00431171 P80003353 Romney, Mitt OLSEN, JUDITH RAMSEY 7 07446 HOMEMAKER HOMEMAKER 500 08-OCT-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 933475 SA18.3252287.26.V011 G2012
432 C00431171 P80003353 Romney, Mitt OLSEN, JUDITH RAMSEY 7 07446 SELF HOMEMAKER 55 07-SEP-12 NaN NaN NaN SA17A 944828 SA17.2412909 G2012
433 C00431171 P80003353 Romney, Mitt OLSEN, JUDITH RAMSEY 7 07446 HOMEMAKER HOMEMAKER 74 10-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2466154.26.V007 G2012
434 C00431171 P80003353 Romney, Mitt CARMOUCHE, GEORGE BATON ROUGE 77 70810 CARMOUCHE CARMOUCHE & BALDWIN LLC ATTORNEY 350 25-SEP-12 NaN NaN NaN SA17A 944828 SA17.2816978 G2012
435 C00431171 P80003353 Romney, Mitt CARMOUCHE, GEORGE BATON ROUGE 77 70810 CARMOUCHE CARMOUCHE & BALDWIN LLC ATTORNEY 350 25-SEP-12 NaN NaN NaN SA17A 822044 SA17.2816978 G2012
436 C00431171 P80003353 Romney, Mitt TUNIS, JEFF D. MR. BRIGANTNE 8 08037 ADVANCED SERVICE SOLUTIONS INC. SELF-EMPLOYED 120 21-SEP-12 NaN NaN NaN SA17A 822044 SA17.2726372 G2012
437 C00431171 P80003353 Romney, Mitt TUNIS, JEFF D. MR. BRIGANTNE 8 08037 ADVANCED SERVICE SOLUTIONS INC. SELF-EMPLOYED 120 21-SEP-12 NaN NaN NaN SA17A 944828 SA17.2726372 G2012
438 C00431171 P80003353 Romney, Mitt BUCKNER, CHRISTINA ODGEN 84 84403 USAFR RETIRED 150 11-SEP-12 NaN NaN NaN SA17A 944828 SA17.2488934 G2012
439 C00431171 P80003353 Romney, Mitt BUCKNER, CHRISTINA ODGEN 84 84403 USAFR RETIRED 150 11-SEP-12 NaN NaN NaN SA17A 822044 SA17.2488934 G2012
440 C00431171 P80003353 Romney, Mitt GIBSON, ROBERT D. MR. SUNLAND 91 91040 FREELANCE STUNTMAN 120 21-SEP-12 NaN NaN NaN SA17A 822044 SA17.2726364 G2012
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1594066 C00431171 P80003353 Romney, Mitt JOERGER, ALBERT G. MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 2500 22-JUN-11 NaN NaN NaN SA17A 944268 SA17.448658 P2012
1594067 C00431171 P80003353 Romney, Mitt JOERGER, PAULINE W. MRS. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 2500 22-JUN-11 NaN NaN NaN SA17A 944268 SA17.448387 P2012
1594068 C00431171 P80003353 Romney, Mitt VAN BUREN, ROBERT MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 1000 03-DEC-12 NaN NaN NaN SA17A 934756 SA17.4349982 G2012
1594069 C00431171 P80003353 Romney, Mitt KOCHE, DAVID L. MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 1000 22-JUN-11 NaN NaN NaN SA17A 944268 SA17.448676 P2012
1594070 C00431171 P80003353 Romney, Mitt KOCHE, LISA S. MRS. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 1000 22-JUN-11 NaN NaN NaN SA17A 944268 SA17.448674 P2012
1594071 C00431171 P80003353 Romney, Mitt LEE, CHARLES L. MR. JR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 500 07-JUN-11 NaN NaN NaN SA17A 944268 SA17.438512 P2012
1594072 C00431171 P80003353 Romney, Mitt LEE, RICHARD H. MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 1000 22-JUN-11 NaN NaN NaN SA17A 944268 SA17.448409 P2012
1594073 C00431171 P80003353 Romney, Mitt LASSITER, A. MR. INFO REQUESTED XX 99999 RAYMOND JAMES & ASSOCIATES BANKER 2500 17-JUN-11 NaN NaN NaN SA17A 944268 SA17.445149 P2012
1594074 C00431171 P80003353 Romney, Mitt LASSITER, MARY ANN MRS. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 2500 17-JUN-11 NaN NaN NaN SA17A 944268 SA17.445163 P2012
1594075 C00431171 P80003353 Romney, Mitt LIBERTY, MICHAEL A. MR. INFO REQUESTED XX 99999 KATAHDIN CORPORATION REAL ESTATE 2500 25-MAY-11 NaN NaN NaN SA17A 944268 SA17.432600 P2012
1594076 C00431171 P80003353 Romney, Mitt KROLLERBERG, MARTIN MR. INFO REQUESTED XX 99999 STATE OF MICHIGAN STATE REPRESENTATIVE 500 27-JUN-11 NaN NaN NaN SA17A 944268 SA17.451445 P2012
1594077 C00431171 P80003353 Romney, Mitt VANVLECK, STANLEY O. MR. INFO REQUESTED XX 99999 SELF-EMPLOYED ATTORNEY 2500 14-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2579501.34.V008 G2012
1594078 C00431171 P80003353 Romney, Mitt TURNER, CHARLES MR. INFO REQUESTED XX 75158 RETIRED RETIRED 250 11-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2501499.26.V008 G2012
1594079 C00431171 P80003353 Romney, Mitt TERRELL, JO ELLEN MS. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 2500 14-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2590027.25.V008 P2012
1594080 C00431171 P80003353 Romney, Mitt TERRELL, JO ELLEN MS. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 2500 14-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2590027.26.V008 G2012
1594081 C00431171 P80003353 Romney, Mitt VANVLECK, STANLEY O. MR. INFO REQUESTED XX 99999 SELF-EMPLOYED ATTORNEY 500 14-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2579501.33.V008 P2012
1594082 C00431171 P80003353 Romney, Mitt RODRIGUEZ, PEDRO NELSON MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 1000 24-AUG-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2166587.1.V007 P2012
1594083 C00431171 P80003353 Romney, Mitt REVERING, SHIRLEY MRS. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 500 13-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2548472.25.V008 P2012
1594084 C00431171 P80003353 Romney, Mitt REVERING, SHIRLEY MRS. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 2500 13-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2548472.26.V008 G2012
1594085 C00431171 P80003353 Romney, Mitt POHRER, JACK E. MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 1000 13-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2584175.26.V008 G2012
1594086 C00431171 P80003353 Romney, Mitt HALL, JULIA MS. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 2500 17-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2641259.26.V008 G2012
1594087 C00431171 P80003353 Romney, Mitt BROWN, BRADLEY N. MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 250 21-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2745851.26.V009 G2012
1594088 C00431171 P80003353 Romney, Mitt CUMMINGS, CHRISTOPHER MR. INFO REQUESTED XX 99999 SELF-EMPLOYED SPORTS MANAGEMENT 1000 17-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2647122.34.V008 G2012
1594089 C00431171 P80003353 Romney, Mitt CREEL, KEVIN MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 1000 24-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2803819.26.V009 G2012
1594090 C00431171 P80003353 Romney, Mitt GRAHOVAC, LIDIJA MS. INFO REQUESTED XX 99999 SELF-EMPLOYED VOLUNTEER 500 04-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2365843.26.V007 G2012
1594091 C00431171 P80003353 Romney, Mitt CURTISS, NICHOLAS E. MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 250 18-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2676875.26.V009 G2012
1594093 C00431171 P80003353 Romney, Mitt DREUX CONSULTING L.L.C. INFO REQUESTED XX 99999 NaN NaN 250 07-SEP-12 NaN NaN ATTRIBUTION TO PARTNERS REQUESTED SA17A 944828 SA17.2462622 G2012
1594094 C00431171 P80003353 Romney, Mitt TURNER, JOHN R. MR. INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 100 28-SEP-12 NaN NaN NaN SA17A 944828 SA17.2935445 G2012
1594095 C00431171 P80003353 Romney, Mitt ARYA, KERRY DR. INFO REQUESTED XX 99999 I.M.S. PHYSICIAN 250 18-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2667420.26.V009 G2012
1594096 C00431171 P80003353 Romney, Mitt ARYA, SUNHA INFO REQUESTED XX 99999 INFORMATION REQUESTED PER BEST EFFORTS INFORMATION REQUESTED PER BEST EFFORTS 250 18-SEP-12 NaN X TRANSFER FROM ROMNEY VICTORY INC. SA18 944828 SA18.2667376.26.V009 G2012

1576478 rows × 18 columns


In [8]:
# Calculate the total positive donations to Obama and Romney
totalOb = 0
totalRom = 0

for row in obama['contb_receipt_amt']:
    amountOb = float(row)
    totalOb += amountOb

for row in romney['contb_receipt_amt']:
    amountRom = float(row)
    totalRom += amountRom

Barack Obama received 4,078,945 non-refund/non-zero donations for the 2012 president election, totaling \$558,359,124.90. The minimum donation was \$0.01, and the maximum amount was \$16,387,179.20. His average donation amount was \$136.89, and the median amount was \$50.00.


In [9]:
# Obama's campaign finance stats:
print "Total positive donations: $%s" % totalOb
obama.describe()


Total positive donations: $558359124.9
Out[9]:
contb_receipt_amt
count 4078945.000000
mean 136.888123
std 10883.523683
min 0.010000
25% 20.000000
50% 50.000000
75% 100.000000
max 16387179.200000

On the other hand, Mitt Romney received 1,576,478 non-refund/non-zero donations for the election, totaling \$679,994,941.51. The minimum amount was \$0.01, and the maximum amount was \$30,000. Despite having fewer donors than Obama, Romney received higher average donation at \$431.34 and higher median amount at \$100.50.


In [10]:
# Romney's campaign finance stats:
print "Total positive donations: $%s" % totalRom
romney.describe()


Total positive donations: $679994941.51
Out[10]:
contb_receipt_amt
count 1576478.000000
mean 431.338047
std 724.779886
min 0.010000
25% 50.000000
50% 100.500000
75% 350.000000
max 30000.000000

Comparing Obama's and Romney's campaign donations by states

Across 50 states and Washington D.C., Obama out raised Romney in only 14 states that are Democratic stronghold: California, District of Columbia, Delaware, Hawaii, Illinois, Massachusetts, Maryland, Maine, New Mexico, New York, Oregon, Rhode Island, Vermont, Washington. The 3 states where Obama received the highest amount of donations were Illinois (\$96.25 million), California (\$93.64 million) and New York (\$51.73 million). The 3 states where Romney received the highest amount of donations were California (\$79.06 million), Texas (\$70.05 million) and Florida (\$58.76 million).


In [15]:
# Aggregate Obama's non-refund/non-zero donations by States
obaState = obama[obama['contbr_st'].isin(['AK', 'AL', 'AR', 'AZ', 'CA', 
                                          'CO', 'CT', 'DC', 'DE', 'FL', 
                                          'GA', 'HI', 'IA', 'ID', 'IL', 
                                          'IN', 'KS', 'KY', 'LA', 'MA', 
                                          'MD', 'ME', 'MI', 'MN', 'MO', 
                                          'MS', 'MT', 'NC', 'ND', 'NE', 
                                          'NH', 'NJ', 'NM', 'NV', 'NY', 
                                          'OH', 'OK', 'OR', 'PA', 'RI', 
                                          'SC', 'SD', 'TN', 'TX', 'UT', 
                                          'VA', 'VT', 'WA', 'WI', 'WV', 'WY'])]

obst = obaState.groupby('contbr_st')

In [28]:
# obaState.groupby('contbr_st').agg(['mean', 'count', 'std'])
obst_sum = obst['contb_receipt_amt'].agg([np.sum, np.mean, len])
obst_sum.columns = ["Obama's total donations ($)", "Obama's average donation ($)", 
                    "Obama's number of donations by state"]

In [20]:
# Aggregate Romney's non-refund/non-zero donations by States
romState = romney[romney['contbr_st'].isin(['AK', 'AL', 'AR', 'AZ', 'CA', 
                                            'CO', 'CT', 'DC', 'DE', 'FL', 
                                            'GA', 'HI', 'IA', 'ID', 'IL', 
                                            'IN', 'KS', 'KY', 'LA', 'MA', 
                                            'MD', 'ME', 'MI', 'MN', 'MO', 
                                            'MS', 'MT', 'NC', 'ND', 'NE', 
                                            'NH', 'NJ', 'NM', 'NV', 'NY', 
                                            'OH', 'OK', 'OR', 'PA', 'RI', 
                                            'SC', 'SD', 'TN', 'TX', 'UT', 
                                            'VA', 'VT', 'WA', 'WI', 'WV', 'WY'])]

rmst = romState.groupby('contbr_st')

In [30]:
rmst_sum = rmst['contb_receipt_amt'].agg([np.sum, np.mean, len])
rmst_sum.columns = ["Romney's total donations ($)", "Romney's average donation ($)", 
                    "Romney's number of donations by state"]

In [31]:
camst = pd.concat([obst_sum, rmst_sum], axis=1)
camst


Out[31]:
Obama's total donations ($) Obama's average donation ($) Obama's number of donations by state Romney's total donations ($) Romney's average donation ($) Romney's number of donations by state
contbr_st
AK 1381715.270000 102.311386 13505 1442757.99 300.136882 4807
AL 2294366.010000 92.690422 24753 7577573.41 377.256468 20086
AR 1325963.500000 103.834260 12770 3564955.91 438.224451 8135
AZ 6619365.540000 84.433914 78397 14345640.43 322.729307 44451
CA 93638609.420000 130.571012 717147 79060173.72 413.853941 191034
CO 11266696.450000 103.726755 108619 16963554.56 371.161267 45704
CT 8454331.020000 128.851463 65613 17010449.85 678.220559 25081
DC 14060203.950000 204.013523 68918 4857768.75 720.416543 6743
DE 1370555.860000 111.363928 12307 1364076.26 360.390029 3785
FL 23286292.340000 110.343272 211035 58758841.89 467.806551 125605
GA 9793278.880000 102.276471 95753 21062034.19 401.893529 52407
HI 2612742.570000 109.760652 23804 1219329.78 299.442480 4072
IA 2582561.900000 88.374291 29223 3824957.98 329.226888 11618
ID 1003673.080000 82.416906 12178 4401368.35 356.386101 12350
IL 96252121.489999 483.880822 198917 24847177.32 450.244216 55186
IN 4016191.260000 85.569218 46935 7506201.82 367.860908 20405
KS 1987405.870000 84.772474 23444 5283899.54 386.843806 13659
KY 2508981.740000 99.369549 25249 6382043.54 434.803348 14678
LA 2499367.720000 105.418521 23709 8767761.37 473.293461 18525
MA 24411416.580000 146.669730 166438 19772247.42 518.398768 38141
MD 19360071.320000 130.406855 148459 11479598.01 364.223555 31518
ME 2839545.650000 130.081344 21829 1165720.48 263.737665 4420
MI 9875275.230000 101.525411 97269 17679279.60 420.594747 42034
MN 7233818.810000 105.906225 68304 7240814.32 388.268235 18649
MO 4843060.890000 100.030174 48416 11806761.98 492.297126 23983
MS 991812.220000 96.236389 10306 4418312.69 435.001742 10157
MT 1138140.720000 98.925747 11505 2061563.16 419.357844 4916
NC 10607641.940000 99.278800 106847 14561324.30 358.080027 40665
ND 281255.770000 80.107026 3511 1051871.84 334.139720 3148
NE 1094626.230000 85.430908 12813 3756842.68 436.537611 8606
NH 2612833.600000 109.223042 23922 3239341.49 347.867428 9312
NJ 12968323.280000 115.915901 111877 18337611.94 459.497142 39908
NM 3840360.350000 101.925802 37678 3509394.66 367.168305 9558
NV 2608817.490000 93.865991 27793 7244556.93 400.894081 18071
NY 51726373.010000 154.867526 334004 42755204.39 634.934278 67338
OH 8655565.560000 95.548699 90588 20969706.62 417.739882 50198
OK 2154238.700000 95.910187 22461 9440038.81 509.116536 18542
OR 7690177.740000 98.205496 78307 4944881.65 292.683140 16895
PA 15322546.180000 113.598794 134883 22900322.81 437.438116 52351
RI 1550860.080000 111.596753 13897 1225917.48 341.766791 3587
SC 2774526.910000 96.629642 28713 6982620.93 329.058479 21220
SD 411322.920000 86.557854 4752 1524330.10 437.397446 3485
TN 4777246.880000 102.346913 46677 12438586.49 447.463360 27798
TX 24724974.320000 109.352704 226103 70054605.32 471.961123 148433
UT 2029313.370000 98.039199 20699 16114398.25 356.931762 45147
VA 17110290.230000 117.791601 145259 26842169.69 393.609058 68195
VT 2445994.030000 127.269579 19219 569061.14 270.081224 2107
WA 16982395.310000 116.215093 146129 11761049.90 336.944561 34905
WI 5220405.520000 100.190107 52105 8928095.50 398.807143 22387
WV 908745.850000 91.607445 9920 2054688.63 436.517661 4707
WY 775764.370000 124.221677 6245 2624590.58 501.450245 5234

In [76]:
# Plot Obama's campaign donations to Plotly
import plotly.plotly as py

ob = pd.read_csv('obama donations', delimiter='\t')

for col in ob.columns:
    ob[col] = ob[col].astype(str)

scl = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],\
            [0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]

data = [ dict(
        type='choropleth',
        colorscale = scl,
        autocolorscale = False,
        locations = ob['State'],
        z = ob["Obama's total donations ($)"].astype(float),
        locationmode = 'USA-states',
        marker = dict(
            line = dict (
                color = 'rgb(255,255,255)',
                width = 2
            )
        ),
        colorbar = dict(
            title = "Millions USD"
        )
    ) ]

layout = dict(
        title = '2012 Obama Campaign Donations by State',
        geo = dict(
            scope='usa',
            projection=dict( type='albers usa' ),
            showlakes = True,
            lakecolor = 'rgb(255, 255, 255)',
        ),
    )
    
fig = dict(data=data, layout=layout)

url = py.plot(fig, validate=False, filename='d3-obama-map')

In [78]:
from IPython.display import Image
Image(filename='obama.png')


Out[78]:

In [79]:
# Plot Romney's campaign donations to Plotly
import plotly.plotly as py

rm = pd.read_csv('romney donations', delimiter='\t')

for col in rm.columns:
    rm[col] = rm[col].astype(str)

scl = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],\
            [0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]

data = [ dict(
        type='choropleth',
        colorscale = scl,
        autocolorscale = False,
        locations = rm['State'],
        z = rm["Romney's total donations ($)"].astype(float),
        locationmode = 'USA-states',
        marker = dict(
            line = dict (
                color = 'rgb(255,255,255)',
                width = 2
            )
        ),
        colorbar = dict(
            title = "Millions USD"
        )
    ) ]

layout = dict(
        title = '2012 Romney Campaign Donations by State',
        geo = dict(
            scope='usa',
            projection=dict( type='albers usa' ),
            showlakes = True,
            lakecolor = 'rgb(255, 255, 255)',
        ),
    )
    
fig = dict(data=data, layout=layout)
url = py.plot(fig, validate=False, filename='d3-romney-map')

In [80]:
Image(filename='romney.png')


Out[80]:

Comparing Obama's and Romney's monthly campaign donations between March 2011 and December 2012

Mitt Romney received donations early beginning in May 2011 as he prepared to enter the Republican presidential primaries (February 1st 2012 - April 1st 2012). His donations increased significantly in April 2012 after he clinched the Republican nomination. Obama, on the other hand, began his re-election campaign in January 2012 and he was formally nominated as President at the Democratic National Convention in Charlotte, North Carolina, on September 6th 2012. Obama finalized his campaign on November 6th 2012 as he was re-elected with 51% popular vote and 332 electorate votes.


In [81]:
%matplotlib inline
from collections import defaultdict
import matplotlib.pyplot as plt
import csv, sys, datetime

reader = csv.DictReader(open("donations.txt", 'r'))

obamadonations = defaultdict(lambda:0)
romneydonations = defaultdict(lambda:0)

In [82]:
for row in reader:
    name = row['cand_nm']
    datestr = row['contb_receipt_dt']
    amount = float(row['contb_receipt_amt'])
    date = datetime.datetime.strptime(datestr, '%d-%b-%y')

    if 'Obama' in name:
        obamadonations[date] += amount
    if 'Romney' in name:
        romneydonations[date] += amount

In [83]:
fig = plt.figure(figsize=(12,6))    # create a 12-inch x 6-inch figure
sorted_by_dateob = sorted(obamadonations.items(), key=lambda (key,val): key)
sorted_by_datemc = sorted(romneydonations.items(), key=lambda (key,val): key)
xs1,ys1 = zip(*sorted_by_dateob)
xs2,ys2 = zip(*sorted_by_datemc)
plt.plot(xs1, ys1, label="Obama's Donations")
plt.plot(xs2, ys2, label="Romney's Donations")
plt.legend(loc='upper center', ncol = 4)


Out[83]:
<matplotlib.legend.Legend at 0x10e1d9ed0>

Comparing Obama's and Romney's cumulative campaign donations between March 2011 and December 2012

Mitt Romney and Barack Obama had similar cumulative donation amounts until September 2012, after Obama and Biden were formally nominated for President and Vice President at the 2012 Democratic National Convention. The increased donations to Mitt Romney likely signaled efforts by his contributors to reach out to potential voters through ground work and television commercials.


In [84]:
import csv,sys,datetime,collections
import itertools
import matplotlib.pyplot as plt

reader = csv.DictReader(open("donations.txt", 'r'))

totaldonations = collections.defaultdict(list)

In [85]:
for row in reader:
    name = row['cand_nm']
    datestr = row['contb_receipt_dt']
    amount = float(row['contb_receipt_amt'])
    date = datetime.datetime.strptime(datestr, '%d-%b-%y')
    
    if 'Obama' in name or 'Romney' in name:
        totaldonations[name].append((date, amount))

campaigntotals = dict([(name, sum(map(lambda p:p[1], val))) for name, val
                   in totaldonations.iteritems()])

In [86]:
fig = plt.figure(figsize=(12,6))

idx = 0
# Obama's and Romney's cumulative donations
for name, monies in totaldonations.iteritems():
    monies.sort(key=lambda pair: pair[0])
    i = itertools.groupby(monies, key=lambda p: p[0])
    monies = map(lambda (key, pairs): (key, sum([float(pair[1]) for pair in pairs])), i)
    total = 0
    newmonies = []
    for pair in monies:
        total += pair[1]
        newmonies.append((pair[0], total ))
    monies = newmonies

    xs,ys = zip(*monies)
    plt.plot(xs, ys, label = name + "'s donations")
    idx += 1
plt.legend(loc='upper center', ncol = 4)


Out[86]:
<matplotlib.legend.Legend at 0x109c38e10>

Comparing Obama's and Romney's cumulative campaign reattributions between March 2011 and December 2012

In the campaign finance dataset, we see some of the data where the donation amount is negative. A quick modification of the code to output only the negative donation amounts:

import csv, sys, datetime
reader = csv.DictReader(open("donations.txt", 'r'))
for row in reader:
    name = row['cand_nm']
    datestr = row['contb_receipt_dt']
    amount = float(row['contb_receipt_amt'])
    if amount < 0:
        line = '\t'.join(row.values())
        print line

As it turns out, "redesignations" and "reattributions" of donations are normal. For instance, if a donation by person A is excessive, the part that exceeds the limits can be "reattributed" to person B, meaning that person B donated the rest to the campaign. Alternatively, the excess amount can be redesignated to another campaign in the same party. So a donation to Romney could be redesignated to a poor republican in Nebraska. However, "Reattribution to spouse" can be suspicious. A potential theory is that CEOs and wealthy contributors use it as a tactic to hide campaign contributions. For example, a CEO could donate money, then reattribute them to the donor's spouse. Then the spouse will donate that amount to the election candidate. In this way, a casual browser will find it difficult to notice that a the candidate is supoorted by a company's CEOs.

The campaign data indicates that Obama did not receive any reattributed donation but Romney received about \$4.1 million in reattribution especially between June 2012 and October 2012 when the presidential election race heated up.


In [87]:
import csv,sys,datetime,collections
import itertools
import matplotlib.pyplot as plt

reader = csv.DictReader(open("donations.txt", 'r'))

totalreattributions = collections.defaultdict(list)

In [88]:
for row in reader:
    name = row['cand_nm']
    datestr = row['contb_receipt_dt']
    amount = float(row['contb_receipt_amt'])
    date = datetime.datetime.strptime(datestr, '%d-%b-%y')
    reason = row['receipt_desc']
    
    if amount < 0 and 'REATTRIBUTION' in reason:
        if 'Obama' in name or 'Romney' in name:
            totalreattributions[name].append((date, -amount))

candreattributions = dict([(name, sum(map(lambda p:p[1], val))) for name, val
                   in totalreattributions.iteritems()])

In [89]:
fig = plt.figure(figsize=(12,6))

idx = 0
# Obama's and McCain's cumulative reattributions
for name, monies in totalreattributions.iteritems():
    monies.sort(key=lambda pair: pair[0])
    i = itertools.groupby(monies, key=lambda p: p[0])
    monies = map(lambda (key, pairs): (key, sum([float(pair[1]) for pair in pairs])), i)
    total = 0
    newmonies = []
    for pair in monies:
        total += pair[1]
        newmonies.append((pair[0], total ))
    monies = newmonies

    xs,ys = zip(*monies)
    plt.plot(xs, ys, label = name + "'s reattributions")
    idx += 1
plt.legend(loc='upper center', ncol = 4)


Out[89]:
<matplotlib.legend.Legend at 0x10e2652d0>

Comparing Obama's and Romney's cumulative campaign refunds between March 2011 and December 2012


In [90]:
import csv,sys,datetime,collections
import itertools
import matplotlib.pyplot as plt

reader = csv.DictReader(open("donations.txt", 'r'))

totalrefunds = collections.defaultdict(list)

In [91]:
for row in reader:
    name = row['cand_nm']
    datestr = row['contb_receipt_dt']
    amount = float(row['contb_receipt_amt'])
    date = datetime.datetime.strptime(datestr, '%d-%b-%y')
    reason = row['receipt_desc']
    
    if amount < 0 and 'Refund' in reason:
        if 'Obama' in name or 'Romney' in name:
            totalrefunds[name].append((date, -amount))

candrefunds = dict([(name, sum(map(lambda p:p[1], val))) for name, val
                   in totalrefunds.iteritems()])

In [92]:
fig = plt.figure(figsize=(12,6))

idx = 0
# Obama's and McCain's cumulative reattributions
for name, monies in totalrefunds.iteritems():
    monies.sort(key=lambda pair: pair[0])
    i = itertools.groupby(monies, key=lambda p: p[0])
    monies = map(lambda (key, pairs): (key, sum([float(pair[1]) for pair in pairs])), i)
    total = 0
    newmonies = []
    for pair in monies:
        total += pair[1]
        newmonies.append((pair[0], total ))
    monies = newmonies

    xs,ys = zip(*monies)
    plt.plot(xs, ys, label = name + "'s refunds")
    idx += 1
plt.legend(loc='upper center', ncol = 4)


Out[92]:
<matplotlib.legend.Legend at 0x109c75f10>

Comparing distribution of Obama's and Romney's campaign donations

Because of the large number of outliers, I display the campaign donation distribution for both candidates within \$0 and \$1,500. Obama is on the right and Romney is on the left of the violin plot, and it indicates that Obama's donations were more concentrated in the smaller amounts between \$25 and \$150 while Romney's donations spanned a larger range.


In [116]:
import seaborn as sns
sns.set_style("whitegrid")

obrom = donations[(donations['cand_nm'].isin(['Obama, Barack', 'Romney, Mitt'])) &
                 (donations['contb_receipt_amt'] < 1200)]

obrom2 = obrom[obrom['contb_receipt_amt'] > 0]

In [117]:
fig = plt.figure(figsize=(8,12))
ax = sns.violinplot(x="cand_nm", y="contb_receipt_amt", data=obrom2)


Performing ttests on Obama's and Romney's campaign donations data

I perform a Welch's T-test on the data to determine if the difference between Romney's and Obama's average campaign contribution is significant. The reported p-value is within rounding error of 0, which is statistically significant.


In [118]:
# Part I
# Run Welch's T-test on donations.txt. Is the difference between Romney and Obama's average 
# compaign contribution significant?
import csv,sys,datetime,collections
import numpy
import scipy.stats
import welchttest

reader = csv.DictReader(open("donations.txt", 'r'))
idx = 0

candtomoney = collections.defaultdict(list)

In [119]:
for row in reader:
    name = row['cand_nm']
    amount = float(row['contb_receipt_amt'])
    candtomoney[name].append(amount)

obama = candtomoney["Obama, Barack"]
romney = candtomoney["Romney, Mitt"]

In [120]:
print "Welch's T-Test p-value:", welchttest.ttest(obama, romney)


Welch's T-Test p-value: 0.0

Because the Welch's T-test makes no assumption about the size of the dataset or its variances, I have likely violated the assumption that the campaign finance data is normally distributed. I conduct the Shapiro-Wilk test to check if the data is actually normal for both presidential candidates. In this case, the test calculates a p-value and tells us that it is not normally distributed if the p-value <0.05.

Obama has a Shapiro-Wilks p-value of 0.000577, which indicates that I have violated the normality assumption of the Welch's T-test.


In [121]:
print "Obama's Shapiro-Wilks p-value", scipy.stats.shapiro(obama)
print "Romney's Shapiro-Wilks p-value", scipy.stats.shapiro(romney)


Obama's Shapiro-Wilks p-value (0.0005766153335571289, 0.0)
Romney's Shapiro-Wilks p-value (0.6059192419052124, 0.0)
/Users/shengli/anaconda/lib/python2.7/site-packages/scipy/stats/morestats.py:1082: UserWarning:

p-value may not be accurate for N > 5000.

Because T-Tests are resilient to breaking of the normality assumption and there are nonparametric equivalents that don't make normality assumptions, I run the Mann-Whitney U nonparametric T-test to determine on the campaign dataset. The reported p-value is about 0, so the result is still statistically significant.


In [122]:
print "mann-whitney U", scipy.stats.mannwhitneyu(obama, romney)


mann-whitney U MannwhitneyuResult(statistic=1801695785317.0, pvalue=0.0)

Which occupations were more generous to either candidate?

Among the campaign contributors that donated to either Barack Obama or Mitt Romney, only 13 contributors from 8 different occupations personally contributed at least \$5,000 to Obama's re-election campaign. On the other hand, 167 individuals from 36 different occupations (primarily chief executive officers, presidents and business owners) donated at least \$5,000 to Romney's re-election campaign


In [143]:
obama = donations[(donations['cand_nm'] == 'Obama, Barack') & 
                  (donations['contb_receipt_amt'] > 5000)]
obOcc = obama.groupby('contbr_occupation')

In [149]:
obOcc_sum = obOcc['contb_receipt_amt'].agg([np.sum, np.mean, len])
obOcc_sum.columns = ["Obama's total donations ($)", "Obama's average donation ($)", 
                    "Number of donors"]
obOcc_sum


Out[149]:
Obama's total donations ($) Obama's average donation ($) Number of donors
contbr_occupation
ARTIST/ PERSONAL ORGANIZER 39200 39200 1
ATTORNEY 25800 25800 1
CEO 10000 10000 1
DOCUMENTARY PHOTOGRAPHER 10000 10000 1
FINANCIAL CONSULTANT 7750 7750 1
INFORMATION REQUESTED 35000 17500 2
PROFESSOR 20000 20000 1
PUBLIC RELATIONS 33300 33300 1
RETIRED 93800 23450 4

In [145]:
romney = donations[(donations['cand_nm'] == 'Romney, Mitt') & 
                  (donations['contb_receipt_amt'] > 5000)]
rmOcc = romney.groupby('contbr_occupation')

In [150]:
rmOcc_sum = rmOcc['contb_receipt_amt'].agg([np.sum, np.mean, len])
rmOcc_sum.columns = ["Romney's total donations ($)", "Romney's average donation ($)", 
                    "Number of donors"]
rmOcc_sum


Out[150]:
Romney's total donations ($) Romney's average donation ($) Number of donors
contbr_occupation
ATTORNEY 20000.00 10000.000000 2
BANKER 15000.00 7500.000000 2
BUSINESS 25000.00 25000.000000 1
BUSINESS OWNER 20000.00 10000.000000 2
BUSINESS SALES 20000.00 10000.000000 2
BUSINESSMAN 20000.00 10000.000000 2
C.E.O 20000.00 10000.000000 2
C.E.O. 20000.00 10000.000000 2
C.O.O. 30074.00 7518.500000 4
CEO 20000.00 10000.000000 2
CEO/OWNER 15000.00 7500.000000 2
CFO 20000.00 10000.000000 2
CHAIRMAN 40000.00 10000.000000 4
CHIEF OPERATING OFFICER 15000.00 7500.000000 2
CIVIC LEADER 20000.00 10000.000000 2
CONSULTANT 27544.51 9181.503333 3
COO 20000.00 10000.000000 2
DEVELOPER. CLERGY 20000.00 10000.000000 2
ENGINEER 20000.00 10000.000000 2
EXECUTIVE 40000.00 10000.000000 4
FOUNDER & CHAIRMAN 15000.00 7500.000000 2
HEALTHCARE 20000.00 10000.000000 2
HOME BUILDER 8000.00 8000.000000 1
HOMEMAKER 37500.00 9375.000000 4
HOUSEWIFE 20000.00 10000.000000 2
IMPORT/EXPORT 20000.00 10000.000000 2
INFORMATION REQUESTED PER BEST EFFORTS 372100.00 10056.756757 37
INVESTMENT BANKER 20000.00 10000.000000 2
INVESTMENTS 9000.00 9000.000000 1
INVESTOR 40000.00 10000.000000 4
MANAGEMENT 11000.00 5500.000000 2
MANAGER 28600.00 28600.000000 1
NATUROPATHIC SURGEON 17600.00 8800.000000 2
NONE 40000.00 10000.000000 4
PARTNER 30000.00 30000.000000 1
PHYSICIAN 80000.00 10000.000000 8
PRESIDENT 40000.00 10000.000000 4
PRESIDENT & C.E.O. 20000.00 10000.000000 2
REAL ESTATE 16000.00 8000.000000 2
RESTAURANT OWNER 20000.00 10000.000000 2
RETIRED 247332.00 9160.444444 27
SALES 20000.00 10000.000000 2
SENIOR MANAGING DIRECTOR 10000.00 10000.000000 1
VICE CHAIRMAN 20000.00 10000.000000 2
VICE PRESIDENT 10828.62 5414.310000 2
VINTNER/OWNER 20000.00 10000.000000 2

Resource

The 2012 Presidential Campaign Contributions dataset is available here.


In [ ]: